home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_objc.idb / usr / freeware / include / cakit / integer.h.z / integer.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  1.6 KB  |  103 lines

  1.  
  2. /*
  3.  * Computer Algebra Kit (c) 1992,98 by Comp.Alg.Objects.  All Rights Reserved.
  4.  * $Id: integer.h,v 1.1.1.1 1999/03/22 21:48:43 stes Exp $
  5.  */
  6.  
  7. #ifndef __CAINTEGER_HEADER__
  8. #define __CAINTEGER_HEADER__
  9.  
  10. #include "cobject.h"
  11.  
  12. #define BigInt Integer
  13.  
  14. typedef struct bigint {
  15.   int sign;
  16.   int count;
  17.   int capacity;
  18.   void *digits;
  19. } *bigint_t;
  20.  
  21. typedef unsigned short int DIGIT;
  22.  
  23. @interface Integer : CAObject
  24. {
  25.   struct bigint value;
  26. }
  27.  
  28. + new;
  29. + str:(STR)aString;
  30. + int:(int)intValue;
  31. + factorial:(int)n;
  32. + fibonacci:(int)n;
  33. - copy;
  34. - deepCopy;
  35. - clear;
  36.  
  37. - (unsigned) hash;
  38. - (BOOL) isEqual:b;
  39. - (int) numDigits;
  40. - (BOOL) isDigit;
  41.  
  42. - insertDigit:(DIGIT)d;
  43. - (DIGIT) removeDigit;
  44.  
  45. - (DIGIT) digitAt:(int)i;
  46. - (DIGIT) lastDigit;
  47. - (DIGIT) leadingDigit;
  48.  
  49. - (STR) str;
  50. - str:(STR)aString;
  51.  
  52. - asNumerical;
  53. - asModp:(unsigned short)p;
  54. - (DIGIT) digitValue;
  55. - digitValue:(DIGIT)aValue;
  56. - (unsigned long) ulongValue;
  57. - ulongValue:(unsigned long)aValue;
  58. - (int) intValue;
  59. - intValue:(int)aValue;
  60. - (double) doubleValue;
  61. - (float) floatValue;
  62.  
  63. - (int) sign;
  64. - (int) compare:b;
  65.  
  66. - zero;
  67. - (BOOL) isZero;
  68. - (BOOL) isOpposite:b;
  69. - negate;
  70. - double;
  71. - add:b;
  72. - subtract:b;
  73. - addDigit:(DIGIT)d;
  74. - subtractDigit:(DIGIT)d;
  75.  
  76. - one;
  77. - minusOne;
  78. - (BOOL) isOne;
  79. - (BOOL) isMinusOne;
  80. - square;
  81. - multiply:b;
  82. - multiplyDigit:(DIGIT)d;
  83. - inverse;
  84.  
  85. - divide:b;
  86. - divideDigit:(DIGIT)b;
  87. - quotientDigit:(DIGIT)b;
  88. - remainder:b quotient:(id *)q;
  89. - quotientDigit:(DIGIT)d remainder:(DIGIT *)r;
  90. - (DIGIT) remainderDigit:(DIGIT)d;
  91.  
  92. - (BOOL) isEven;
  93. - (BOOL) isOdd;
  94.  
  95. - gcd:b;
  96.  
  97. - (BOOL) printsLeadingSign;
  98. - printOn:(IOD)aFile;
  99. @end
  100.  
  101. #endif                /* __CAINTEGER_HEADER__ */
  102.  
  103.